<?php defined('SYSPATH') OR die('No direct script access.');

class Stourweb_View extends Class_View {
    //定义视图缓存目录
    public $_view_cache_dir = 'phone';

    /**引用文件
     * @param string 引入文件名
     * */
    public static function template($file)
    {
        $tpl = $GLOBALS['cfg_default_templet'] . '/' . $file;

        if (!file_exists(APPPATH . '/views/' . $GLOBALS['cfg_default_templet'] . '/' . $file . '.php'))
        {
            $tpl = 'default/' . $file;
        }
        echo Stourweb_View::factory($tpl, self::$_user_data);
    }

    /**
     * Sets the view filename.
     *
     *     $view->set_filename($file);
     *
     * @param   string $file view filename
     * @return  View
     * @throws  View_Exception
     */
    public function set_filename($file)
    {
        $this->_templet = $file; //模板文件

        if (($path = Kohana::find_file('views', $file)) === FALSE)
        {
            //标准模板不存在 则检测在用户模板是否存在
            $tpl = DOCROOT . $file . '.php';


            if (file_exists($tpl))
            {
                $path = DOCROOT . $file . '.php';



            }
            else
            {
                throw new View_Exception('The requested view :file could not be found', array(
                    ':file' => $file,
                ));
            }
        }

        // Store the file path locally
        $this->_file = $path;

        return $this;
    }

}

